package as3 
{
	import as3.main.Config;
	import as3.main.MainData;
	import as3.main.MainData;
	import flash.display.Sprite;
	import flash.events.Event;
	import Cain.MkMc.FullMdMk;
	/**
	 * 框架
	 * @author cain in liontravel 2010
	 */
	public class Main extends Sprite 
	{
		private const PATH_DIR:String = "pcx"; //照片資料夾
		private var mcmk:FullMdMk;
		private var _data:MainData;
		private var _config:Config;
		public function Main() 
		{
			setup();
		}
		private function setup():void
		{
			addEventListener(Event.ADDED_TO_STAGE, onADDED_TO_STAGE);
		}
		private function onADDED_TO_STAGE(e:Event):void 
		{
			addEventListener(Event.REMOVED_FROM_STAGE, onREMOVED_FROM_STAGE);
			init();
		}
		private function init():void
		{
			mcmk = new FullMdMk(this, 900, 600);
			mcmk.loading("", .5, "LOADMV");
			_data = new MainData(PATH_DIR);
			_config = new Config(_data);
			_data.addEventListener(MainData.DATA_READY, onDATA_READY);
			addEventListeners();
		}
		
		private function onDATA_READY(e:Event):void 
		{
			_data.removeEventListener(MainData.DATA_READY, onDATA_READY);
			mcmk.remove();
			
		}
		
		private function addEventListeners():void
		{
			
		}
		private function removeEventListeners():void
		{
			
		}
		private function onREMOVED_FROM_STAGE(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, onADDED_TO_STAGE);
			removeEventListener(Event.REMOVED_FROM_STAGE, onREMOVED_FROM_STAGE);
			removeEventListeners();
		}
	}
	
}